home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / 80x0393.zip / VIDTYPE.ASM < prev    next >
Assembly Source File  |  1993-03-30  |  37KB  |  1,111 lines

  1. comment *
  2.  
  3.         Author:
  4.         Yousuf J. Khan
  5.  
  6.         Purpose:
  7.         To detect what type of video adapter is installed.
  8.  
  9.         Note:
  10.         Work was based on source code inside Richard Wilton's
  11.         "Programmer's Guide to PC & PS/2 Video Systems" book. However
  12.         it's been heavily reworked to a more (dare I say?)
  13.         understandable format. Also Super VGA tests were put in,
  14.         something completely missing from Wilton's book.
  15.  
  16.         *
  17.  
  18. .model tiny
  19.  
  20. ;.stack 200h
  21.  
  22. .data
  23. std0type        db      0       ;first video subsystem type
  24. ext0type        db      0       ;extended info on first subsystem
  25. std1type        db      0       ;second video subsystem type
  26. ext1type        db      0       ;extended info on second subsystem
  27. vidflag         record  monofound:1,colorfound:1
  28. egatype         vidflag <0,0>   ;Was a mono or color EGA found?
  29. ;
  30. ;video adapter codes (based on codes returned by VGA BIOS DC codes):
  31. ;-these codes are used when a VGA BIOS is not found and other tests
  32. ; need to be performed to determine video type
  33. ;-it was decided to use the VGA BIOS DC codes for simplicity
  34. ;-see findVGA procedure for list of VGA DCCs.
  35. ;
  36. NoDISP  equ     0       ;no display
  37. MONO    equ     1
  38. CGA     equ     2
  39. cEGA    equ     4       ;color EGA
  40. mEGA    equ     5       ;mono EGA
  41.  
  42. .code
  43.         org     100h            ;*.COM start offset
  44. start:
  45.         call    findVGA         ;look for a VGA or MCGA
  46.         comment \
  47.  
  48.         After executing VGA BIOS routines, the VGA BIOS itself will have
  49.         done all the work of determining what is installed so no need to
  50.         do any further tests. The "findVGA" subprocedure will set the CF
  51.         upon returning, if a VGA BIOS was found.
  52.  
  53.                 \
  54.         jc      endtests        ;found VGA/MCGA, end of tests
  55.         call    findEGA         ;look for an EGA
  56.         call    findCGA         ;look for a CGA
  57.         call    findMono        ;look for an MDA or HGC
  58. endtests:
  59.         call    write_msg       ;write found info to screen, set
  60.                                 ; errorlevel
  61.         mov     ah, 4ch         ;end program
  62.         int     21h
  63.  
  64. findVGA         proc
  65. comment *
  66.  
  67.         Purpose:
  68.         determine if a MCGA/VGA/SVGA display is installed
  69.  
  70.         Entry:
  71.         nothing
  72.  
  73.         Return:
  74.         CF set if found, clear if not
  75.  
  76.         *
  77.         mov     ax, 1A00h       ;get Displ Combo Code info
  78.         int     10h
  79.         cmp     al, 1Ah         ;VGA-only BIOS function
  80.         jne     noVGA           ; not supported => no VGA
  81. comment \
  82.  
  83.         Upon Return from Int 10h, AX=1A00h:
  84.         BL=primary adapter DCC
  85.         BH=secondary adapter DCC
  86.  
  87.         Values for display combination code:
  88.         00h no display
  89.         01h monochrome adapter w/ monochrome display
  90.         02h CGA w/ color display
  91.         03h reserved
  92.         04h EGA w/ color display
  93.         05h EGA w/ monochrome display
  94.         06h PGA w/ color display
  95.         07h VGA w/ monochrome analog display
  96.         08h VGA w/ color analog display
  97.         09h reserved
  98.         0Ah MCGA w/ digital color display
  99.         0Bh MCGA w/ monochrome analog display
  100.         0Ch MCGA w/ color analog display
  101.         FFh unknown display type
  102.  
  103.         \
  104.         push    bx              ;interpretDCC destroys contents of BH
  105.         call    interpretDCC    ;this proc looks for extended info
  106.         mov     [std0type], bl  ;save normal info
  107.         mov     [ext0type], bh  ;save extended info
  108.         pop     bx
  109.         push    bx
  110.         ;Since proc interpretDCC only works on info in BL, we must
  111.         ; exchange BL with BH.
  112.         xchg    bh, bl          
  113.         call    interpretDCC
  114.         mov     [std1type], bl  ;save normal info
  115.         mov     [ext1type], bh  ;save extended info
  116.         pop     bx
  117.         stc             ;found VGA/MCGA, so set CF before ret
  118.         jmp     endVGAtest
  119. noVGA:
  120.         clc
  121. endVGAtest:
  122.         ret
  123.  
  124.         interpretDCC    proc
  125.         comment *
  126.  
  127.                 Purpose:
  128.                 Interprets information returned by the DCC
  129.  
  130.                 Upon Entry:
  131.                 BL=normal DCC of desired video subsystem
  132.                 BH=will be destroyed, replaced with ext code
  133.  
  134.                 Upon Return:
  135.                 BL=normal DCC returned (MDA,CGA,EGA,PGA,MCGA,VGA,etc)
  136.                 BH=extended code (HGC,SVGA), 0 if none
  137.  
  138.                 *
  139.                 mov     bh, 0   ;Assume no extended attribs
  140.                 cmp     bl, 0   ;If 0, then no display card
  141.                 je      end_interpret
  142.                 cmp     bl, 1   ;Mono
  143.                 je      monotests
  144.                 jmp     CGAtests
  145.         monotests:
  146.         ;
  147.         ;If we find a monochrome adapter, then we need to do special
  148.         ; further tests to see if we have just an MDA or one of the
  149.         ; Hercules cards.
  150.         ;
  151.                 mov     bh, bl          ;save normal DCC in BH
  152.                 call    findHGC         ;MDA or HGC? value returned in
  153.                                         ; BL
  154.                 xchg    bh, bl          ;BL=normal,BH=extended
  155.                 jmp     end_interpret
  156.         CGAtests:
  157.                 cmp     bl, 2           ;CGA
  158.                 je      end_interpret
  159.                 cmp     bl, 6           ;EGA or PGA
  160.                 jbe     end_interpret
  161.                 cmp     bl, 8           ;BL=7,8: VGA
  162.                 ja      end_interpret
  163.         ;
  164.         ;If we find a VGA, then we need to do extra tests to see whose
  165.         ; VGA chipset it is.
  166.         ;
  167.                 mov     bh, bl          ;save BL in BH
  168.                 call    findSVGA        ;search for SVGA adapter
  169.                 xchg    bh, bl          ;BH=extended, BL=normal
  170.         end_interpret:
  171.                 ret
  172.                 endp
  173.         endp
  174.  
  175. findSVGA        proc
  176. comment *
  177.  
  178.         Purpose:
  179.         To search for specific SVGA types, including VESA compatibility.
  180.  
  181.         Entry:
  182.         Nothing
  183.  
  184.         Return:
  185.         BL=SVGA type
  186.  
  187.         *
  188. comment \
  189.  
  190.         List of SVGA types:
  191.         Brand           Type
  192.         -----           ----
  193.         ATI             1─┐
  194.         Ahead           2 │ These chipsets all have
  195.         Paradise        3 │ easily identifiable BIOS based
  196.         Oak             4 │ identification methods.
  197.         Genoa           5─┘
  198.         Cirrus          6─┐
  199.         Chips&Tech      7 │ These chipsets require complicated
  200.         Tseng           8 │ register twiddlings to identify
  201.         ZyMos           9 │ their presense.
  202.         Trident        10─┘
  203.         8514/A         11   -checks for HDILOAD.EXE only
  204.  
  205.         If a VESA BIOS is present, then add 128 to errorlevels.
  206.  
  207.         Note: The BIOS based id strings were obtained from Ralf Brown's
  208.         PD DOS Interrupts list (INTER32).
  209.  
  210.         The register level chipset tests were obtained through various
  211.         sources, including John Bridges' VGAKIT 5.0, and Andrew
  212.         Rossmann's INFOPLUS 1.55 source code. However, both gentlemen
  213.         appear to have gotten their info through the book "Advanced
  214.         Programmer's Guide to Super VGAs", by George Sutty and Steve
  215.         Blair. So lay credit wherever you like.
  216.  
  217.         \
  218.         noSVGA  equ     0
  219.         mov     bl, noSVGA      ;initially assume no SVGA
  220.         push    es              ;save current ES segment
  221.         mov     ax, 0C000h      ;set ES to VBIOS
  222.         mov     es, ax          ; segment (C000h)
  223.         ;
  224.         ;now testing for ATI chipset
  225.         ;
  226.         .data
  227.         ATIid   db      "761295520"
  228.         idlen   =       $-ATIid
  229.         ATI     equ     1
  230.         .code
  231.         mov     di, 31h         ;id string offset in ATI VBIOS
  232.         mov     si, offset ATIid
  233.         mov     cx, idlen
  234.         repe    cmpsb   ;comp each byte, exit if not matched
  235.         jne     noATI
  236.         mov     bl, ATI         ;ATI was found
  237.         jmp     endSVGAtests
  238. noATI:
  239.         ;
  240.         ;now testing for Ahead chipset
  241.         ;
  242.         .data
  243.         AHEADid db      "AHE